<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="templateUsuarios.xhtml">

	<ui:define name="header">
	</ui:define>

	<ui:define name="menu">
	</ui:define>

	<ui:define name="content">
		<h:form prependId="false">

			<p:growl id="growl" showDetail="false" />
			<p:panel header="Gerenciar Pessoas" style="font-size: 14px;">
				<p:toolbar>
					<p:toolbarGroup align="left">
						<p:commandButton type="push" value="Novo" alt="Cadastrar Pessoa"
							oncomplete="modalEdit.show();" image="ui-icon-document"
							update="editPanel" actionListener="#{pessoaBean.novaPessoa}" />
					</p:toolbarGroup>
				</p:toolbar>
				<p:dataTable value="#{pessoaBean.pessoas}" var="pessoa"
					id="listPessoas"
					emptyMessage="Nenhuma pessoa encontrada na base de dados">
					<p:column headerText="#{msg.nomePessoa}">
						<h:outputText value="#{pessoa.nome}" />
					</p:column>
					<p:column headerText="#{msg.cpf}">
						<h:outputText value="#{pessoa.cpf}" />
					</p:column>
					<p:column headerText="#{msg.dataNascimento}">
						<h:outputText value="#{pessoa.dataNascimento}">
							<f:convertDateTime pattern="dd/MM/yyyy"
								timeZone="America/Sao_Paulo" />
						</h:outputText>
					</p:column>
					<p:column headerText="#{msg.sexo}">
						<h:outputText value="#{pessoa.sexo}" />
					</p:column>
					<p:column headerText="#{msg.estadoCivil}">
						<h:outputText value="#{pessoa.estadoCivil.descricao}" />
					</p:column>
					<p:column headerText="#{msg.medico}"
						sortBy="#{pessoaBean.medico.id}">
						<h:commandLink>
							<p:graphicImage title="Dados do medico" style="border: none;"
								width="50" height="50" value="images/medic.png"
								rendered="#{pessoa.medico != null}" />
						</h:commandLink>
					</p:column>
					<p:column headerText="#{msg.usuario}">
						<h:outputText value="#{pessoa.usuario.login}" />
					</p:column>
					<p:column headerText="#{msg.senha}">
						<h:outputText value="#{pessoa.usuario.senha}" />
					</p:column>

					<p:column headerText="#{msg.acoes}">
						<p:commandLink oncomplete="modalEdit.show();"
							action="#{pessoaBean.doEditPerson}" update="modalEdit,editPanel">
							<p:graphicImage title="Editar" style="border: none;"
								alt="Editar Pessoa" value="images/editPerson.png" height="50"
								width="45" />
							<f:setPropertyActionListener value="#{pessoa}"
								target="#{pessoaBean.pessoa}" />
						</p:commandLink>
						<p:spacer width="10" style="border: none;" />
						<h:commandLink action="#{pessoaBean.removePessoa}">
							<p:graphicImage title="Deletar" style="border: none;"
								alt="Deletar Pessao" value="images/delete.png" height="50"
								width="50" />
							<f:setPropertyActionListener value="#{pessoa}"
								target="#{pessoaBean.pessoa}" />
						</h:commandLink>
						<p:spacer width="10" style="border: none;" />
						<h:commandLink action="marcarConsulta">
							<p:graphicImage title="Marcar Consulta" style="border: none;"
								alt="Deletar Pessao" value="images/consulta.png" height="50"
								width="50" />
							<f:setPropertyActionListener value="#{pessoa}"
								target="#{pessoaBean.pessoa}" />
						</h:commandLink>
					</p:column>

				</p:dataTable>
			</p:panel>

		</h:form>
	</ui:define>

	<ui:define name="dialogs">
		<ui:include src="cadastroPessoa.xhtml" />
	</ui:define>
</ui:composition>